<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title>商机信息</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui-win.css" />
	<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<style>
.content{margin-top: 10px;}
.mainDiv{width: 90%;margin: 0 auto;}
.userImg ul li{list-style: none;display: inline-block;width: 15%;}
.userImg ul li img{width: 100%;height: 50%;}
.userImg p{line-height: 25px;}
#stat img{margin-right:8px;width:18px;height:18px;}
#img{width: 80%;height: 150px;}
#visitors img{width: 40px;height: 40px;border-radius: 30px;}
#title{height: 30px;white-space: nowrap;text-overflow: ellipsis;}
#visitors{margin-top: 5px;width: 100%;}
#visitors img{margin-right: 1%;}
.contact h4{padding-left: 5%;background: #F2F2F2;height: 30px;line-height: 30px;font-weight: 500;}
.contact div{padding-left: 5%;line-height: 30px;}
.describe h4{padding-left: 5%;background: #F2F2F2;font-weight: 500;height: 30px;line-height: 30px;}
#pub-name img{width: 100px;height: 100px;}
.describe div{width: 90%;margin-left: 5%;text-indent: 2em;line-height: 30px;}
.icon{padding: 0px 0px 0px 3px;}
#praises, #comments{position: relative;bottom: 2px;}
a em{color: blue;}
.striping{margin-top: 10px;height: 10px;background: #f5f5f5;}
/*slide*/
.swipe{overflow: hidden;visibility: hidden;position: relative;}
.swipe-wrap{overflow: hidden;position: relative;}
.swipe-wrap > figure{float: left;width: 100%;position: relative;}
#slider{margin: 0px auto;}
figure{margin: 0;}
.swipe-wrap img{width: 100%;}
nav{position: absolute;right: 10px;bottom: 12px;overflow: hidden;}
#position{text-align: center;margin: 0;padding: 0;}
#position li{width: 6px;height: 6px;border-radius: 50%;background: #141414;margin: 0 2px;cursor: pointer;float: left;}
#position li.on{background-color: #1293dc;}
.contact label{font-weight:bold;}
#imge111{transform: rotate(180deg);}
figure img{width: 100%;}
</style>
</head>
<body style="background:none;">
    <div class="div_loding_img">
		数据加载中
	</div>
	<header class="aui-bar aui-bar-nav aui-bar-yunzo" id="aui-header">
		<a class="aui-btn aui-bar-yunzo aui-pull-left" id="back" > <span class="aui-iconfont aui-icon-left"></span></a>
		<div class="aui-title" id="title">
			商机详情
		</div>
		<a class="aui-iconfont aui-icon-menu aui-pull-right"><i class="fa fa-share-alt"></i></a>
	</header>
	<div class="margin_div"></div>
	<div class="content">
			<div id="slider" class="swipe" style="visibility:visible;">
		    <div class="swipe-wrap">
		    </div>
		  	<nav>
			    <ul id="position">
			    </ul>
			</nav>
		</div>
		
		<div class="mainDiv">
			<h3 style="margin-top:10px;margin-bottom:10px;font-size:16px;"><span id="bstitle" style="font-weight:bold;color:#00abfd;font-size:18px;"></span></h3>
			<div class="userImg">
				<p style="color:#666;">
					共有<span id="counts"></span>人看过 <span style="float:right;right:2.5%;" id="stat"></span>
				</p>
				<div id="visitors"></div>
			</div>
		</div>
		<div class="contact">
			<h4 style="color:#444;font-size:16px">联系方式</h4>
			<div>
				<label>联系人：</label><span id="username"></span>
			</div>
			<div>
				<label>电<span style="color:white;">空</span>话：</label><span><a href="" id="tel"></a></span>
			</div>
			<div>
				<label>行<span style="color:white;">空</span>业：</label><span id="type"></span>
			</div>
			<div>
				<label>地<span style="color:white;">空</span>域：</label><span id="addr"></span>
			</div>
			<div>
				<label>有效期：</label><span id="limitime"></span>
			</div>
			<div>
				<label>发布人：</label><a id="pub-name"></a>
			</div>
		</div>
		<div class="describe">
			<h4 style="color:#444;font-size:16px;">描述</h4>
			<div id="in-detial"></div>
		</div>
		<div class="striping"></div>
	</div>
<script src="../../script/jquery-1.10.2.min.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/swipe.js"></script>
<script type="text/javascript">
var types;
var mid;
var did;
var groupid;
var title;
var logoImg;
var bussCopny;
var bussTime;
var bussPub;
var bussBrws;
var bussComts;
var bussPris;
var infoid;
var collectinfo;
var memberids;
var htmlAll="";
var html="";
var flag = 0;
var collectinfo;
var postparam;
var baseDatas;
var visitors

$(document).ready(function(){
	
	visitors = $('#visitors');
	infoid = getUrlParam("infoid");
	title = getUrlParam("title");
	//logoImg = getUrlParam("logoImg");
	//bussCopny = getUrlParam("bussCopny");
	//bussTime =getUrlParam("bussTime");
	//bussPub = getUrlParam("bussPub");
	//bussBrws = getUrlParam("bussBrws");
	//bussComts =getUrlParam("bussComts");
	//bussPris = getUrlParam("bussPris");
	flag = getUrlParam("isColltect");
	//alert(flag+"<========isColltect");
	did=initdata.get('busessinfo');
    baseDatas=basedata('busessinfo');
    postparam =baseDatas+"&bid="+infoid;
    
	collectinfo =  title + "," + infoid;
	//alert(broCunt+" "+comCunt+" "+praCunt)
	$('#bstitle').html(title);
	loadaction(postparam);
	getdata(postparam)
});
sTart_Stop();
function loadaction(post) {
	ajaxCoCRequest('../../../api/group/getTop5buessinfobyAction?'+post, 'POST', '', function(msg) {
		if (msg.code == 100) {
			var thisItem = msg.datum;
			var stat = $('#stat');
			stat.html('');
			var html1 = '';
			var collectSrc;
			var praiseSrc;
			if (thisItem.n4 == 0) {
				flag=1;
				collectSrc = '../../image/home/busess/soucang1.png';
			} else {
				flag=0;
				collectSrc = '../../image/home/busess/soucang222.png'
			}
			if (thisItem.n3 == 0) {
				praiseSrc = '../../image/home/busess/nozan.png';
			} else {
				praiseSrc = '../../image/home/busess/zan.png';
			}
			html1 += '<img class="icon" id="collected" src="' + collectSrc + '" onclick="collectUp()"><span id="collect"></span>'
			html1 += '<img class="icon" src="' + praiseSrc + '" onclick="thumbUp(\'' + infoid + '\',\'' + thisItem.n3 + '\')"><span id="praises"></span>'
			html1 += '<img class="icon" src="../../image/home/busess/pinglun.png" onclick="openNews(\'' + infoid + '\', \'' + did + '\')"><span id="comments"></span>'
	
			stat.append(html1);
			$('#comments').innerHTML = thisItem.n1;
			$('#praises').innerHTML = thisItem.n2;
			$("img").error(function(){
	        	  $(this).attr("src","../../image/defaultImg2.png") 
	           });
		} else {
			$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
		}
	})
}
function getdata(post)
{   
	ajaxcocRequest('../../../api/group/getgroupbusinessinfobybid','post',post,function(msg){
	   		if(msg.code==100){
		   		var counts = $('#counts');
				var username = $('#username');
				var tel = $('#tel');
				var type = $('#type');
				var addr = $('#addr');
				var limitime = $('#limitime');
				var detial = $('#in-detial');
				var pubName = $('#pub-name');
				
				var thisItem = msg.datum;
				var arr=[];
				if(thisItem.n0!=null){
					arr=thisItem.n0.split(",");
				}
				loadingimage(arr);
				if (thisItem.n9 != null) {
					var src;
					counts.html(thisItem.n9.length);
					for (var i = 0, len = thisItem.n9.length; i < len; i++) {
						if (thisItem.n9[i].n1 != null&&thisItem.n9[i].n1!="") {
							if (thisItem.n9[i].n1.indexOf(",") != -1) {
								htmlAll += '<img onclick="opeinmemberinfo(\'' + thisItem.n9[i].n0 + '\')" src="' + thisItem.n9[i].n1.split(",")[0] + '">';
							} else
								htmlAll += '<img onclick="opeinmemberinfo(\'' + thisItem.n9[i].n0 + '\')" src="' + thisItem.n9[i].n1 + '">';
						} else {
							
							htmlAll += '<img  onclick="opeinmemberinfo(\'' + thisItem.n9[i].n0 + '\')" src="../../image/defaultImg1.png">';
						}
					}
					htmlAll += '<img src="../../image/home/busess/showMore.png" onclick="closeDiv()" id="imge111">'
					for (var i = 0, len = thisItem.n9.length; i < len; i++) {
						if(i <= 4){
							if (thisItem.n9[i].n1 != null&&thisItem.n9[i].n1 !=""){
								if (thisItem.n9[i].n1.indexOf(",") != -1){
									html += '<img onclick="opeinmemberinfo(\'' + thisItem.n9[i].n0 + '\')" src="' + thisItem.n9[i].n1.split(",")[0] + '">';
								} 
								else{
									html+='<img onclick="opeinmemberinfo(\'' + thisItem.n9[i].n0 + '\')" src="' + thisItem.n9[i].n1 + '">';
								}	
							} 
							else {
								html+='<img  onclick="opeinmemberinfo(\'' + thisItem.n9[i].n0 + '\')" src="../../image/defaultImg1.png">';
							}
						} 
						else if(i == 5){
							html+='<img src="../../image/home/busess/showMore.png" onclick="showDiv()">'
						}
					}
				} else {
					counts.html(0);
					html += '<img  src="../../image/defaultImg1.png">';
				}

				visitors.append(html);
				var memberids = thisItem.n7;
				username.html(thisItem.n1);
				tel.html(thisItem.n2);
				addr.html(thisItem.n4);
				limitime.html(thisItem.n5);
				detial.html(thisItem.n6);
				pubName.html(thisItem.n8);
				pubName.attr("onclick","opeinmemberinfo(\'" + thisItem.n7 + "\')");
				$("#tel").attr("href","tel:"+thisItem.n2);
				$("img").error(function(){
		        	  $(this).attr("src","../../image/defaultImg2.png");
		        });
				type.html(thisItem.n3);
				/*if(thisItem.n3!=""){
					for(var k=0;k<arr_industry1.length;k++){
						if(thisItem.n3==arr_industry1[k]){
							type.html(arr_industry[k]);
						}
					}
				}
				else{
					type.html("他（她）还没有选择行业");
				}*/
	   		} else {
	   			$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>');
			}
	   	});
}
function opeinmemberinfo(mid)
{	
	if($mids=="135000000001"){
		mssg();
	}
	else{
		window.location ="selfinfo.html?infoid="+mid;
	}

}
function loadingimage(arr)
{	
	var html='';
	var phtml='';
	var h=$(window).width() * 0.75;
	var swipeWrap=$(".swipe-wrap");
	var positions=$("#position");
	if(arr==""){
		html+='<figure><div class="face faceInner"><img src="../../image/defaultImg2.png"></div></figure>';
		phtml+='<li class="on"></li>';
	}
	
	for(var i=0;i<arr.length;i++){
		if(arr[i]==null){
			arr[i]="../../image/defaultImg2.png";
		}
		html+='<figure><div class="face faceInner"><img src="'+arr[i]+'" style="height:'+h+'px;"/></div></figure>';
		
		if(i==0)
		{
			phtml+='<li class="on"></li>';
		}else
		{
			phtml+='<li class=""></li>';
		}
	}

	swipeWrap.height(h);
	swipeWrap.append(html);
	positions.append(phtml);
	$("img").error(function(){
  	  $(this).attr("src","../../image/defaultImg2.png") 
     });
	initSlide();    
}
//定制的图片轮播函数
function initSlide() {
	var bullets = document.getElementById('position').getElementsByTagName('li');

	var slider=Swipe(document.getElementById('slider'), {
            auto: 5000,
            continuous: true,
            disableScroll : true,
    		stopPropagation : true,
            callback: function(pos) {
                var len = bullets.length;
                for(var i=0;i<len;i++)
                {
                    bullets[i].className = ' ';
                }
                if(pos==len)
                	bullets[0].className = 'on';
                else
                	bullets[pos].className = 'on';
            }
        });
}
//收藏
function mssg(){
	var mymessage=confirm("无法使用该功能，请下载APP应用！")
	if(mymessage==true){
		location.href="http://114.215.201.200:8080/coc-manager/cocdownload/bate/index.html";
	}
}
function collectUp() {
	if($mtype=="guest"){
		alert("游客模式请绕行，会员模式请直行");
	}
	else{
		if($mids=="135000000001"){
			mssg();
		}
		else{

		var bodyParam = {"mid":$mid,"groupid":$groupid,"did":did,"pid":infoid,"collectinfo":collectinfo,"type":flag}
		ajaxCoCRequest('../../../api/collectforall', 'POST', bodyParam, function(msg) {
			if (msg.code == 100) {
				if (flag == 0) {
					alert("收藏成功");
					flag = 1;
					//详情展示
					loadaction(postparam);
				}
				else {
					alert("取消收藏");
					flag = 0;
					loadaction(postparam)
				}
			}
			else{
				$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
			}
		});
	}
	}
}
//点赞
function thumbUp(bid, type) {
	if($mids=="135000000001"){
		mssg();
	}
	else{
	ajaxcocRequest('../../../api/userproetformid', 'POST', baseDatas + '&type='+(type==0?1:0)+'&pid=' + bid, function(msg) {
		if (msg.code==100) {
			alert(type==0?"取消点赞！":"点赞成功！");
			//详情展示
			loadaction(postparam);
		} else {
			$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
		}
	})
	}
}
function showDiv() {
	visitors.html("");
	visitors.append(htmlAll);
}

function closeDiv() {
	visitors.html("");
	visitors.append(html);
}


//评论
function openNews(pid,did){
	if($mids=="135000000001"){
		mssg();
	}
	else{
	var localData =  window.localStorage;
	if($mtype=="guest")
		{
			alert("游客模式请绕行，会员模式请直行");
		}else{
	window.location ="comment_info.html?pid="+pid+"&did="+did+"&path=busess_info.html";
	}
	}
} 
$("#back").click(function(){
    goback("busess_list.html");
});

</script>
</body>
</html>